<?php
$dir = dirname(__FILE__);  //找出当前脚本所在路径
/*require $dir.'\lib\PHPExcel_1.8.0_doc\Classes\PHPExcel.php'; //添加读取excel所需的类文件

$objPHPExcel = new PHPExcel();                     //实例化一个PHPExcel()对象
$objSheet = $objPHPExcel->getActiveSheet();        //选取当前的sheet对象
$objSheet->setTitle('helen');                      //对当前sheet对象命名
//常规方式：利用setCellValue()填充数据
$objSheet->setCellValue("A1","张三")->setCellValue("B1","李四");   //利用setCellValues()填充数据
//取巧模式：利用fromArray()填充数据
$array = array(
    array("","B1","张三"),
    array("","B2","李四")
);
$objSheet->fromArray($array);  //利用fromArray()直接一次性填充数据
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel2007');   //设定写入excel的类型
$objWriter->save($dir.'/test.xlsx');*/       //保存文件

//利用php读取excel数据
require $dir.'\lib\PHPExcel_1.8.0_doc\Classes\PHPExcel\IOFactory.php';

$filename = $dir.'\test.xlsx';
$objPHPExcelReader = PHPExcel_IOFactory::load($filename);  //加载excel文件

foreach($objPHPExcelReader->getWorksheetIterator() as $sheet)  //循环读取sheet
{
    foreach($sheet->getRowIterator() as $row)  //逐行处理
    {
        if($row->getRowIndex()<2)  //确定从哪一行开始读取
        {
            continue;
        }
        foreach($row->getCellIterator() as $cell)  //逐列读取
        {
            $data = $cell->getValue(); //获取cell中数据
            echo $data;
        }
        echo '<br/>';
    }
}

?>